<template>
    <div class="login">
        <oheader></oheader>
     
        <div class='oform'>
    <input type="text" name="username" v-model.trim='username' @focus="ofous" placeholder="请输入您的用户名" />
                <h3 v-show='flag1'>请输入您的用户名</h3>

            <input type="password" v-model.trim='pwd'  @focus="ofous" name="password" placeholder="请输入您的密码" />

                <h3 v-show='flag2'>请输入您的密码!</h3>

            <input type="submit"   @click='login' class="sub" name="sub" value="登录" />

            <p><a href='#' class="a3">立即注册</a>
            <a href='#'  class="a5">|</a>
            <a href='#'  class="a4">忘记密码</a></p>
        </div>
        
        

    </div>
</template>

<script>
import oheader from './components/header'
export default {
    data(){
        return{
            flag1:false,
            flag2:false,

            username:'',
            pwd:''
        }
    },
    computed:{
       
    },
    methods:{
        login(){
            this.isnull();
            this.isflag();
            if(this.username !== '' && this.pwd!==''){
                this.$router.push({name:'shoppingcart'});
                this.$store.commit('username',this.username);

            }
        },
        //获得焦点隐藏提示
        ofous(){
            this.flag1=false;
            this.flag2=false;
        },
        //用户名是否为空
        isnull(){
          if(this.username === ''){
              this.flag1 = true;
          }else{
              this.flag1 = false;

          }
        },
        //密码是否为空
         isflag(){
           if(this.pwd === ''){
              this.flag2 = true;
          }else{
              this.flag2 = false;

          }
        }
    },
    components:{
        oheader
    }
}
</script>

<style lang='scss' scoped>
     
 $appwidth:375;


@function pxtovw($p){
    @return (100/$appwidth*$p) * 1vw;
}
.login{
    width: 100%;
    height: 100%;
    position: absolute;
    .oform{
    height:pxtovw(600);
    
   

        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        transform: translateY(pxtovw(50));
        h3{
            color: red;
            margin: pxtovw(20);
        }
        input{
            height: pxtovw(60);
            outline: none;
            border: none;
            border-bottom: 1px solid black;
             font-size: pxtovw(14);
             width: pxtovw(250)
        }
        .sub{
            outline: none;
            border: none;
            background-color:#FF6700; 
            width:pxtovw(250);
            height: pxtovw(40);
            color: white;
            margin-top:pxtovw(20); 
        }
        .sub:hover{
            background-color: rgb(250, 139, 49); 
        }
        a{
            text-decoration: none;
            
        }
        .a3,.a5{
            color: #8D8C8C;
            font-size: pxtovw(14);
        }
        .a3:hover{
            color: orange;
        }
        .a4{
            color: orange;
            font-size: pxtovw(14);

        }
    }
    .hea{
    height:pxtovw(40) ;
    width: 100%;
    background: #F2F2F2;
     color: #6C6B6B;
     text-align: center;
    font-size: pxtovw(14);
    line-height: pxtovw(40) ;
    position: absolute;

 .ospan1{
        display: inline-block;
      position: absolute;
      
    }
    
} 


}


</style>
